#include "regidialog.h"

regidialog::regidialog(QWidget *parent)
	: QDialog(parent)
{
	okButtonClick = false;
	cancelButtonClick = false;
	ui.setupUi(this);
	createInterface();
	connectSlots();
}

regidialog::~regidialog()
{

}

void regidialog::createInterface()
{
	image1Label = new QLabel(this);
	image1Label->setObjectName(QString::fromUtf8("image1"));
	image1Label->setText(QString::fromUtf8("image1"));
	image1Label->setGeometry(QRect(60, 60, 54, 12));
	image2Label = new QLabel(this);
	image2Label->setObjectName(QString::fromUtf8("image1"));
	image2Label->setText(QString::fromUtf8("image2"));
	image2Label->setGeometry(QRect(60, 120, 54, 12));
	image1LineEdit = new QLineEdit(this);
	image1LineEdit->setObjectName(QString::fromUtf8("lineEdit"));
    image1LineEdit->setGeometry(QRect(110, 60, 221, 20));
	image2LineEdit = new QLineEdit(this);
	image2LineEdit->setObjectName(QString::fromUtf8("lineEdit_2"));
    image2LineEdit->setGeometry(QRect(110, 120, 221, 20));
	image1PushButton = new QPushButton(this);
	image1PushButton->setObjectName(QString::fromUtf8("pushButton"));
	image1PushButton->setText(QString::fromUtf8("pushButton"));
    image1PushButton->setGeometry(QRect(350, 60, 21, 23));
	image2PushButton = new QPushButton(this);
	image2PushButton->setObjectName(QString::fromUtf8("pushButton_2"));
	image2PushButton->setText(QString::fromUtf8("pushButton_2"));
    image2PushButton->setGeometry(QRect(350, 120, 21, 23));
	okPushButton = new QPushButton(this);
	okPushButton->setObjectName(QString::fromUtf8("pushButton_3"));
	okPushButton->setText(QString::fromUtf8("Ok"));
    okPushButton->setGeometry(QRect(100, 180, 75, 23));
	cancelPushButton = new QPushButton(this);
	cancelPushButton->setObjectName(QString::fromUtf8("pushButton_4"));
	cancelPushButton->setText(QString::fromUtf8("Cancel"));
    cancelPushButton->setGeometry(QRect(260, 180, 75, 23));

}

void regidialog::connectSlots()
{
	connect(image1PushButton,  SIGNAL(clicked()), this, SLOT(inputImage1()));
	connect(image2PushButton,  SIGNAL(clicked()), this, SLOT(inputImage2()));
	connect(okPushButton, SIGNAL(clicked()), this, SLOT(okClick()));
	connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancelClick()));
}

void regidialog::openImage(QLineEdit *lineEdit)
{
	const QString fileName = QFileDialog::getOpenFileName(this,tr("Open Image"),QDir::currentPath(),tr("Image Files (*.png *.jpg *.bmp)"));
   // if (!fileName.isEmpty()) {
      //  if (!paintArea->openImage(fileName)) {
         //   QMessageBox::information(this, tr("Plug & Paint"),
          //                           tr("Cannot load %1.").arg(fileName));
         //   return;
        //}
       // paintArea->adjustSize();
   // }

	lineEdit->setText(fileName);
}


//slots
void regidialog::inputImage1()
{
	openImage(image1LineEdit);
	image1FilePath = image1LineEdit->text();
}

void regidialog::inputImage2()
{
	openImage(image2LineEdit);
	image2FilePath = image2LineEdit->text();
}

void regidialog::okClick()
{
	//QMessageBox::information(this, tr("Plug & Paint"), tr("ok button click"));
	okButtonClick = true;
	accept();
}

void regidialog::cancelClick()
{
	//QMessageBox::information(this, tr("Plug & Paint"), tr("cancel button click"));
	reject();
}
